'''
Created on 2010-3-3

@author: Administrator
'''
import sys
from jolly.datastructures.PrePostVisitor import PrePostVisitor

class PreOrder(PrePostVisitor):
    '''
    Adapter to convert a Visitor to a PrePostVisitor for pre-order traversal.
    '''


    def __init__(self, visitor):
        '''
        (PreOrder, Visitor) -> None
        Constructs a pre-order visitor from the given visitor.
        '''
        super(PreOrder, self).__init__()
        self._visitor=visitor
    
    def preVisit(self, obj):
        '''
        (PreOrder, Object) -> None
        Pre-visits the given object.
        '''
        self._visitor.visit(obj)
    
    def getIsDone(self):
        '''
        (PreOrder) -> bool
        Returns true if the visitor is done.
        '''
        return self._visitor.isDone
    
    @staticmethod
    def main(*argv):
        'PreOrder test program.'
        print PreOrder.main.__doc__
        return 0

if __name__=="__main__":
    sys.exit(PreOrder.main(*sys.argv))
    
    
        